package com.weirong.smartvault.backservice.controller.fragment_entity;

import java.util.ArrayList;
import java.util.List;

/**
 * 于2017/11/26由 KFEB4 创建 .
 */
public class Menu {
    private String Name;
    private List<Menu> subMenus;
    private String url;

    private Boolean selected;
    public Menu(String Name, String url, List<Menu> subMenu) {
        this.Name = Name;
        this.url = url;
        this.subMenus = subMenu;
    }

    @Override
    public String toString() {
        return this.getName();
    }

    public Boolean getSelected() {
        return selected;
    }

    public void setSelected(Boolean selected) {
        this.selected = selected;
    }

    public String getName() {
        return Name;
    }

    public List<Menu> getSubMenus() {
        return subMenus;
    }

    public String getUrl() {
        return url;
    }

    public String getUrlEnd(){
        String [] urls = this.url.split("/");
        return urls[urls.length-1];
    }
    public String getSpan(){
        return "<span class='caret'> </span>";
    }
    public static List<Menu> BuildMenu(String currentMenu) {
        List<Menu> menus = new ArrayList<>();
            List<Menu> submenus = new ArrayList<>();
            submenus.add(new Menu("数据字典", "/base/dict", null));
            submenus.add(new Menu("机构管理", "/base/org", null));
            submenus.add(new Menu("槽位钞箱管理", "/base/box", null));
            submenus.add(new Menu("钞箱组管理", "/base/box_unit", null));
            submenus.add(new Menu("币种管理", "/base/foreign_currency_type", null));
            submenus.add(new Menu("面额管理", "/base/denomination", null));
        menus.add(new Menu("基础数据", "/base", submenus));

            submenus = new ArrayList<>();
            submenus.add(new Menu("用户管理", "/user/user", null));
            submenus.add(new Menu("角色管理", "/user/role", null));
            submenus.add(new Menu("权限管理", "/user/permission", null));
        menus.add(new Menu("用户管理","/user",submenus));

            submenus = new ArrayList<>();
            submenus.add(new Menu("需求管理", "/currency/request", null));
            submenus.add(new Menu("入库管理", "/currency/storage", null));
            submenus.add(new Menu("库存管理", "/currency/stock", null));
            submenus.add(new Menu("出库管理", "/currency/delivery", null));
        menus.add(new Menu("外币管理","/currency",submenus));

            submenus = new ArrayList<>();
            submenus.add(new Menu("核账", "/confirm/confirm",null));
            submenus.add(new Menu("核账结果", "/confirm/confirm_result", null));
        menus.add(new Menu("核账管理","/confirm",submenus));

            submenus = new ArrayList<>();
            submenus.add(new Menu("指令列表", "/command/command", null));
        menus.add(new Menu("指令管理","/command",submenus));

            submenus = new ArrayList<>();
            submenus.add(new Menu("设备监控", "/monitor/monitor", null));
            submenus.add(new Menu("监控日志", "/monitor/error_log", null));
        menus.add(new Menu("设备监控","/monitor",submenus));

            submenus = new ArrayList<>();
            submenus.add(new Menu("年度币种使用量报表", "/report/use", null));
            submenus.add(new Menu("月度库存使用对比表", "/report/use_detail", null));
            submenus.add(new Menu("年度币种库存报表", "/report/stock", null));
            submenus.add(new Menu("月度库存报表", "/report/stock_detail", null));
            submenus.add(new Menu("年度度库存使用对比表", "/report/compare_stock_use", null));
            // submenus.add(new Menu("按网点库存使用量查询报表", "/report/map", null));
        menus.add(new Menu("报表管理","/report",submenus));

        for(Menu m :menus){
            if (currentMenu.startsWith(m.getUrlEnd())) {
                m.setSelected(Boolean.TRUE);
            }
            else
                m.setSelected(Boolean.FALSE);
        }
        return menus;
    }
}
